﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;

namespace Locator.Products.Views
{
    public class UsersProductsPresenter : Presenter<IUsersProductsView>
    {
        private readonly IProductsController controller;

        public UsersProductsPresenter([CreateNew] IProductsController controller)
        {
            this.controller = controller;
        }

        public override void OnViewLoaded()
        {
            List<UserProduct> usersProducts = this.controller.GetProductsForCurrentUser();
            this.View.SetProducts(usersProducts);
        }

        public override void OnViewInitialized()
        {
            // TODO: Implement code that will be executed the first time the view loads
        }

        public void OnProductDeleted(UserProduct product)
        {
            this.controller.DeleteProductForCurrentUser(product.Id);
        }

        public void OnProductSearchClicked()
        {
            this.controller.ProductSearch();
        }
    }
}




